// @ts-ignore
import js from '@eslint/js';
// @ts-ignore
import globals from 'globals';
// @ts-ignore
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import reactDom from 'eslint-plugin-react-dom';
// 更新 Prettier 导入方式
// @ts-ignore
import prettier from 'eslint-config-prettier';
// @ts-ignore
import pluginPrettier from 'eslint-plugin-prettier';

export default tseslint.config(
    {
        ignores: ['**/node_modules', 'dist', 'build', 'public', '**/*.log'],
    },
    js.configs.recommended,
    ...tseslint.configs.recommendedTypeChecked,
    {
        files: ['**/*.{ts,tsx}'],
        languageOptions: {
            ecmaVersion: 2020,
            globals: globals.browser,
            parserOptions: {
                project: ['./tsconfig.json'],
                tsconfigRootDir: __dirname,
                warnOnUnsupportedTypeScriptVersion: false
            },
        },
        plugins: {
            'react-refresh': reactRefresh,
            'react-dom': reactDom,
            prettier: pluginPrettier,
        },
        rules: {
            'react-refresh/only-export-components': [
                'warn',
                { allowConstantExport: true },
            ],
            ...(typeof reactDom.configs.recommended === 'object'
                ? reactDom.configs.recommended.rules
                : {}),
            'prettier/prettier': "off",
            'no-console': 'off',
            'no-debugger': 'off',
            'max-len': 'off',
            'no-multi-spaces': 'off',
            'no-return-assign': 'off',
            semi: 'off',
            eqeqeq: 'error',
            'jsx-quotes': 'off',
            'import/prefer-default-export': 'off',
            'import/extensions': 'off',
            'import/no-unresolved': 'off',
            'no-multiple-empty-lines': 'off',
            'no-param-reassign': 'off',
            '@typescript-eslint/no-unused-expressions': "off",
            '@typescript-eslint/no-floating-promises': "off",
            '@typescript-eslint/no-unused-vars': "off",
            '@typescript-eslint/prefer-promise-reject-errors': "off",
            '@typescript-eslint/no-unsafe-assignment': 'off',
            '@typescript-eslint/no-unsafe-member-access': 'off',
            '@typescript-eslint/no-unsafe-call': 'off',
            '@typescript-eslint/no-unsafe-return': 'off',
            '@typescript-eslint/no-unsafe-argument': 'off',
            '@typescript-eslint/consistent-file-names': 'off',
            '@typescript-eslint/ban-ts-comment': 'off',
            '@typescript-eslint/prefer-ts-expect-error': 'off',
            '@typescript-eslint/no-shadow': 'off',
            '@typescript-eslint/no-explicit-any': 'off',
            '@typescript-eslint/indent': 'off',
            '@typescript-eslint/no-empty-object-type': 'off',
        },
    },
    // 将 Prettier 配置作为独立的配置对象添加在最后
    {
        ...prettier,
        // 显式设置报告未使用禁用指令的方式
        linterOptions: {
            reportUnusedDisableDirectives: true,
        },
    },
);
